﻿using System;
using System.Collections.Generic;
using UnityEngine;

public static partial class GeneralTool
{
    /// <summary>
    /// 判断list中是否有与value Equal的元素
    /// </summary>
    public static bool ContainsEqual<T>(this List<T> list, T value)
    {
        foreach (T data in list)
        {
            if (data.Equals(value))
                return true;
        }
        return false;
    }

    public static bool TrueForAny<T>(this List<T> list, Predicate<T> match)
        => !list.TrueForAll(x => !match(x));

    public static List<Vector2Int> AllAdd(this List<Vector2Int> list, Vector2Int offset)
    {
        List<Vector2Int> ret = new List<Vector2Int>();
        foreach (Vector2Int v in list)
        {
            ret.Add(v + offset);
        }
        return ret;
    }
    public static List<Vector2> AllAdd(this List<Vector2> list, Vector2 offset)
    {
        List<Vector2> ret = new List<Vector2>();
        foreach (Vector2 v in list)
        {
            ret.Add(v + offset);
        }
        return ret;
    }
}
